// pageMy/shortcut/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
      userId:wx.getStorageSync('userId'),
      userType:wx.getStorageSync('userType'),
      currId:''
  },
onLoad(optiions){
  this.gotoScan()
},
// 扫码
  gotoScan() {
    wx.scanCode({
      onlyFromCamera: true,
        success: (res) => {
            console.log('条码类型：' + res.scanType);
            console.log('条码内容：' + res.result);
            if(!isNaN(parseFloat(res.result)) && isFinite(res.result)){
              // 获取用户详情
            wx.$req({
              url: '/system/user/userInfo/'+res.result,
            }).then(res1 => {
              console.log(res1.data)
                this.setData({
                  info:res1.data.data,
                  currId:res.result
                })
            })
          }else{
              wx.showToast({
                title: '二维码错误',
                icon: 'error',
                duration: 2000 //持续的时间
            });
            setTimeout(() => {
              wx.navigateBack()
            },1000)
          }
        },
        fail: (err) => {
                wx.showToast({
                    title: '二维码错误',
                    icon: 'error',
                    duration: 2000 //持续的时间
                });
                wx.navigateBack()
        }
    });

},
// 跳转操作
  publicTo(e) {
    let url=e.currentTarget.dataset.url
    wx.navigateTo({
      url: url
    })
  }
})